<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../Ajs/vue.min.js"></script>

</head>
<body>
<div id="app">
    水果 循环数组
    <ul>
        <li v-for="item in shuiguo">{{item}}</li>
    </ul>
    <ul>
        <li v-for="(item,index) in shuiguo">{{item}}--{{index}}</li>
    </ul>

    水果 循环对象数组
    <ul>
        <li v-for="(item,index) in shuiguo1">{{index}}--{{item.eName}}--{{item.cName}} </li>
    </ul>

    key的作用：帮助Vue区分不同的元素，从而提高性能
    <ul>
        <li :key="index" v-for="(item,index) in shuiguo1">{{index}}--{{item.eName}}--{{item.cName}} </li>
    </ul>

    v-for 遍历对象
    <ul>
        <li v-for="(v,k,i) in shuiguo2">{{i+"--"+k+ "--"+v}}</li>
    </ul>

    v-for 和 v-if 结合使用
    <ul>
        <li v-if="value.price == 3" v-for="(value,index) in shuiguo1" :key="index">{{value.cName}}--{{value.price}}</li>
    </ul>

</div>

<script>
    var vm = new Vue({
        el:"#app",
        data:{
            shuiguo:["apple","orange","banana"],

            shuiguo1:[{
                eName:"apple",
                cName:"苹果",
                price:"3"
            },{
                eName:"orange",
                cName:"橘子",
                price:"2.5"
            },{
                eName:"banana",
                cName:"香蕉",
                price:"3"
            }],

            shuiguo2:{
                name:"apple",
                num:"1",
                price:"1"
            }
        },
        methods:{}
    })









</script>
</body>
</html>
